#ifndef CLIENT_H
#define CLIENT_H

#include <QDialog>
#include <QTcpSocket>
#include <QHostAddress>
#include <QMessageBox>
#include <QtDebug>
#include <QTime>
#include "database.h"

namespace Ui {
class Client;
}

class Client : public QDialog
{
    Q_OBJECT

public:
    int m_uid;
    QString m_name;
    bool isVIP = false;
    Database myDatabase;
    explicit Client(QWidget *parent = nullptr,int uid = 0);
    ~Client();

private slots:
    void on_Send_clicked();

    void on_Connect_clicked();
    //服务器连接成功时槽函数
    void onConnected();
    //断开连接槽函数
    void onDisconnected();
    //接受消息槽函数
    void onReadyRead();
    //网络异常
    void onError();
private:
    Ui::Client *ui;
    bool status;              //1在线，0离线
    QTcpSocket tcpSocket;     //和服务器通信套接字
    QHostAddress serverIP;    //服务器地址
    quint16 serverPort;       //服务器端口
    QString username;         //聊天室昵称
};

#endif // CLIENT_H
